var t = getApp();

Page({
    data: {
        url: "",
        url2: "",
        id: "",
        sessin: null,
        ht: {},
        saveclass: "保 存",
        condition: !0,
        checkeda: !1,
        checkedb: !1,
        heigth: "height: 550rpx;",
        pic: "../../images/20.png"
    },
    onLoad: function(a) {
        this.setData({
            url: a.url,
            url2: a.url2,
            id: a.id,
            sessin: a.sessin,
            Listurl: a.Listurl,
            TopName: a.TopName,
            From: a.From,
            nav: a.nav
        });
        var e = t.globalData.htGet.partAorB;
        "甲方" == e && this.setData({
            checkeda: !0
        }), "乙方" == e && this.setData({
            checkedb: !0
        }), console.log("结果", a);
    },
    onReady: function() {
        "Model" == this.data.From && this.setData({
            saveclass: "另存为我的文档"
        });
        var a = this.data.sessin, e = wx.getStorageSync("PHPSESSID");
        if (console.log("结2果", e), a === e && e || (this.sessValid(), this.setData({
            checkeda: !1,
            checkedb: !1
        }), t.GetUrl()), 1 == this.data.nav) {
            var i = this, o = this.data.id, s = this.data.url;
            wx.showToast({
                title: "加载中",
                icon: "loading",
                duration: 2e4
            }), wx.request({
                url: t.url + "addon/" + s,
                data: {
                    id: o
                },
                method: "GET",
                header: {
                    "Content-Type": "application/json",
                    Cookie: "PHPSESSID=" + wx.getStorageSync("PHPSESSID")
                },
                success: function(a) {
                    wx.hideToast(), i.setData({
                        ht: a.data
                    }), t.globalData.htGet = a.data, t.globalData.htGet.url = options.url, i.setData({
                        btnbol: !1
                    });
                },
                fail: function(t) {
                    wx.hideToast(), i.setData({
                        netbol: !1
                    }), wx.showToast({
                        title: "无法连接网络",
                        icon: "loading",
                        duration: 2200
                    });
                }
            });
        } else this.setData({
            ht: t.globalData.htGet
        });
    },
    radioChange: function(t) {
        console.log(t), this.setData({
            partAorB: t.detail.value
        });
    },
    Cutheigth: function(t) {},
    Addheigth: function(t) {},
    inpusubmit: function(a) {
        var e = this, i = a.detail.value.title, o = a.detail.value.content, s = this.data.url, n = this.data.url2, d = this.data.id, r = wx.getStorageSync("userInfo"), l = this.data.sessin;
        wx.getStorageSync("PHPSESSID");
        wx.showToast({
            title: "保存中",
            icon: "loading",
            duration: 2e4
        }), wx.request({
            url: t.url + "addon/" + n,
            data: {
                title: i,
                content: o,
                id: d,
                formId: a.detail.formId,
                partAorB: this.data.partAorB,
                nickName: r.nickName,
                city: r.city,
                htbase: "M"
            },
            method: "POST",
            header: {
                "content-type": "application/x-www-form-urlencoded",
                Cookie: "PHPSESSID=" + wx.getStorageSync("PHPSESSID")
            },
            success: function(t) {
                wx.hideToast();
                var a = t.data;
                if (a > 1) wx.showToast({
                    title: "保存成功",
                    icon: "success",
                    duration: 2e3
                }), e.setData({
                    condition: !1,
                    addId: a
                }); else {
                    var i = e.data.Listurl, o = e.data.TopName;
                    wx.redirectTo({
                        url: "../MyCenter/MyCenter?url=" + s + "&url2=" + n + "&sessin=" + l + "&Listurl=" + i + "&TopName=" + o
                    }), wx.showToast({
                        title: "保存成功",
                        icon: "success",
                        duration: 2200
                    });
                }
            },
            fail: function(t) {
                wx.hideToast(), console.log("提交结果2：", t), t && wx.showToast({
                    title: "保存失败无网络",
                    icon: "loading",
                    duration: 2600
                });
            }
        }), t.globalData.seachlist = "", t.globalData.catList = "";
    },
    bindValueinput: function(t) {
        var a = t.detail.value;
        wx.setStorageSync("text", a);
    },
    toExamMy: function(t) {
        wx.redirectTo({
            url: "../../pages/ExamMy/ExamMy?id=" + this.data.addId + "&htbase=SM"
        });
    },
    openContract: function(t) {
        this.data.Listurl, this.data.TopName, this.data.url, this.data.url2;
        var a = wx.getStorageSync("PHPSESSID");
        wx.redirectTo({
            url: "../../pages/Modelht/Modelht?id=" + this.data.addId + "&url=Smcontract/Smcontract/ContractDetail&url2=Smcontract/Smcontract/editContract&sessin=" + a + "&Listurl=Smcontract/Smcontract/&TopName=我起草的合同"
        });
    },
    BackTo: function() {
        var t = this.data.url, a = this.data.url2, e = this.data.id, i = this.data.sessin;
        wx.redirectTo({
            url: "../Modelht/Modelht?url=" + t + "&url2=" + a + "&id=" + e + "&sessin=" + i + "&Listurl=" + this.data.Listurl + "&TopName=" + this.data.TopName + "&From=" + this.data.From
        });
    },
    toIndex: function(t) {
        wx.switchTab({
            url: "../Draft/Draft"
        });
    },
    sessValid: function() {
        wx.request({
            url: t.url + "addon/Pubdata/Pubdata/sessValid",
            data: {},
            method: "GET",
            header: {
                "Content-Type": "application/json",
                Cookie: "PHPSESSID=" + wx.getStorageSync("PHPSESSID")
            },
            success: function(a) {
                console.log(a.data), 0 == a.data && t.WxLogin();
            },
            fail: function(a) {
                t.WxLogin();
            }
        });
    }
});